home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libs / readline / posixstat.h < prev    next >
C/C++ Source or Header  |  1995-09-22  |  5KB  |  158 lines

  1. /* posixstat.h -- Posix stat(2) definitions for systems that
  2.    don't have them. */
  3.  
  4. /* Copyright (C) 1987,1991 Free Software Foundation, Inc.
  5.  
  6.    This file is part of GNU Bash, the Bourne Again SHell.
  7.  
  8.    Bash is free software; you can redistribute it and/or modify it
  9.    under the terms of the GNU General Public License as published by
  10.    the Free Software Foundation; either version 1, or (at your option)
  11.    any later version.
  12.  
  13.    Bash is distributed in the hope that it will be useful, but WITHOUT
  14.    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15.    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  16.    License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with Bash; see the file COPYING.  If not, write to the Free
  20.    Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  21.  
  22. /* This file should be included instead of <sys/stat.h>.
  23.    It relies on the local sys/stat.h to work though. */
  24. #if !defined (_POSIXSTAT_H)
  25. #define _POSIXSTAT_H
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. #include <sys/stat.h>
  32.  
  33. #if defined (isc386)
  34. #  if !defined (S_IFDIR)
  35. #    define S_IFDIR 0040000
  36. #  endif /* !S_IFDIR */
  37. #  if !defined (S_IFMT)
  38. #    define S_IFMT  0170000
  39. #  endif /* !S_IFMT */
  40. #endif /* isc386 */
  41.  
  42. /* This text is taken directly from the Cadmus I was trying to
  43.    compile on:
  44.     the following MACROs are defined for X/OPEN compatibility
  45.     however, is the param correct ??
  46.    #define S_ISBLK(s) ((s.st_mode & S_IFMT) == S_IFBLK)
  47.  
  48.   Well, the answer is no.  Thus... */
  49. #if defined (BrainDeath)
  50. #  undef S_ISBLK
  51. #  undef S_ISCHR
  52. #  undef S_ISDIR
  53. #  undef S_ISFIFO
  54. #  undef S_ISREG
  55. #endif /* BrainDeath */
  56.  
  57. /* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
  58.  
  59. /* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
  60.    do not provide the S_IS* macros that Posix requires. */
  61.  
  62. #if defined (_S_IFMT) && !defined (S_IFMT)
  63. #define S_IFMT _S_IFMT
  64. #endif
  65. #if defined (_S_IFIFO) && !defined (S_IFIFO)
  66. #define S_IFIFO _S_IFIFO
  67. #endif
  68. #if defined (_S_IFCHR) && !defined (S_IFCHR)
  69. #define S_IFCHR _S_IFCHR
  70. #endif
  71. #if defined (_S_IFDIR) && !defined (S_IFDIR)
  72. #define S_IFDIR _S_IFDIR
  73. #endif
  74. #if defined (_S_IFBLK) && !defined (S_IFBLK)
  75. #define S_IFBLK _S_IFBLK
  76. #endif
  77. #if defined (_S_IFREG) && !defined (S_IFREG)
  78. #define S_IFREG _S_IFREG
  79. #endif
  80. #if defined (_S_IFLNK) && !defined (S_IFLNK)
  81. #define S_IFLNK _S_IFLNK
  82. #endif
  83. #if defined (_S_IFSOCK) && !defined (S_IFSOCK)
  84. #define S_IFSOCK _S_IFSOCK
  85. #endif
  86.  
  87. /* Test for each symbol individually and define the ones necessary (some
  88.    systems claiming Posix compatibility define some but not all). */
  89.  
  90. #if defined (S_IFBLK) && !defined (S_ISBLK)
  91. #define    S_ISBLK(m)    (((m)&S_IFMT) == S_IFBLK)    /* block device */
  92. #endif
  93.  
  94. #if defined (S_IFCHR) && !defined (S_ISCHR)
  95. #define    S_ISCHR(m)    (((m)&S_IFMT) == S_IFCHR)    /* character device */
  96. #endif
  97.  
  98. #if defined (S_IFDIR) && !defined (S_ISDIR)
  99. #define    S_ISDIR(m)    (((m)&S_IFMT) == S_IFDIR)    /* directory */
  100. #endif
  101.  
  102. #if defined (S_IFREG) && !defined (S_ISREG)
  103. #define    S_ISREG(m)    (((m)&S_IFMT) == S_IFREG)    /* file */
  104. #endif
  105.  
  106. #if defined (S_IFIFO) && !defined (S_ISFIFO)
  107. #define    S_ISFIFO(m)    (((m)&S_IFMT) == S_IFIFO)    /* fifo - named pipe */
  108. #endif
  109.  
  110. #if defined (S_IFLNK) && !defined (S_ISLNK)
  111. #define    S_ISLNK(m)    (((m)&S_IFMT) == S_IFLNK)    /* symbolic link */
  112. #endif
  113.  
  114. #if defined (S_IFSOCK) && !defined (S_ISSOCK)
  115. #define    S_ISSOCK(m)    (((m)&S_IFMT) == S_IFSOCK)    /* socket */
  116. #endif
  117.  
  118. /*
  119.  * POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
  120.  */
  121.  
  122. #if !defined (S_IRWXU)
  123. #  if !defined (S_IREAD)
  124. #    define S_IREAD    00400
  125. #    define S_IWRITE    00200
  126. #    define S_IEXEC    00100
  127. #  endif /* S_IREAD */
  128.  
  129. #  if !defined (S_IRUSR)
  130. #    define S_IRUSR    S_IREAD            /* read, owner */
  131. #    define S_IWUSR    S_IWRITE        /* write, owner */
  132. #    define S_IXUSR    S_IEXEC            /* execute, owner */
  133.  
  134. #    define S_IRGRP    (S_IREAD  >> 3)        /* read, group */
  135. #    define S_IWGRP    (S_IWRITE >> 3)        /* write, group */
  136. #    define S_IXGRP    (S_IEXEC  >> 3)        /* execute, group */
  137.  
  138. #    define S_IROTH    (S_IREAD  >> 6)        /* read, other */
  139. #    define S_IWOTH    (S_IWRITE >> 6)        /* write, other */
  140. #    define S_IXOTH    (S_IEXEC  >> 6)        /* execute, other */
  141. #  endif /* !S_IRUSR */
  142.  
  143. #  define S_IRWXU    (S_IRUSR | S_IWUSR | S_IXUSR)
  144. #  define S_IRWXG    (S_IRGRP | S_IWGRP | S_IXGRP)
  145. #  define S_IRWXO    (S_IROTH | S_IWOTH | S_IXOTH)
  146. #endif /* !S_IRWXU */
  147.  
  148. /* These are non-standard, but are used in builtins.c$symbolic_umask() */
  149. #define S_IRUGO        (S_IRUSR | S_IRGRP | S_IROTH)
  150. #define S_IWUGO        (S_IWUSR | S_IWGRP | S_IWOTH)
  151. #define S_IXUGO        (S_IXUSR | S_IXGRP | S_IXOTH)
  152.  
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156.  
  157. #endif /* _POSIXSTAT_H */
  158.